<HEAD>
  <SCRIPT SRC="../ganja.js"></SCRIPT>
</HEAD>
<BODY><SCRIPT>
// the OPNS visualizer can be used to visualize degenerate elements
// for which the parametric form is unknown. It works by raytracing
// a boundary on the length of the outer product.

// We demonstrate in CGA. The OPNS visualizer only works for the graded
// algebra generator, so we have to specify that when we create our algebra :
Algebra({p:4,q:1,graded:true},()=>{
  
  // As usual, we start by defining a null basis, and upcasting for points
    var ni = 1e4+1e5, no = .5e5-.5e4, nino = ni^no;
    var up = (x)=> no + x + .5*x*x*ni;
 
  // for OPNS viz we also need an "up" version that uses only basis blades :
    var upviz = up(Element.Vector("x","y","z")).Vector;
  
  // Next we create some points
    var p1 = up(1e3-1e1), p2 = up(-1e3-1e1), p3 = up(1e2-1e1);
        
  // We create a circle and a line.
    var c1 = (p1^p2^p3).Normalized, c2 = (p3^p2^ni).Normalized;

  // Now we will use the OPNS visualizer to show how the shape of the
  // object evolves as we interpolate from one to the other.
    document.body.appendChild(this.graph(()=>{
       // factor between 0 and 1     
       var t = Math.min(1,Math.max(0,0.5 + 0.75*Math.sin(performance.now()/700)));
       // interpolate
       var i = c1*t+(1-t)*c2;
       // graph in pretty blue.
       return [0x0088FF,i]
    },{up:upviz, h:Math.PI/2, animate:1}))
    
})
</SCRIPT></BODY>